package com.qf.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Value("${item.itemQueueName}")
    private String itemQueueName;

    @Value("${es.esExchangeName}")
    private String esExchangeName;

    @Value("${es.esRouting}")
    private String esRouting;

    @Bean
    public Queue itemQueue(){
        return new Queue(itemQueueName,true,false,false);
    }

    @Bean
    public TopicExchange esExchange(){
        return new TopicExchange(esExchangeName,true,false);
    }

    @Bean
    public Binding emailQueueBindingExchange() {
        return BindingBuilder.bind(itemQueue()).to(esExchange()).with(esRouting);
    }

}
